var_type=[10,10.0,"luck",(1,2,3),[1,2,3],set([1,2,3]),{"name":'jhk'}]

for i in var_type:
   t=type(i)

   add1=id(i)
   print("变量类型",t,"初始值",i,"初始内存地址",add1)

   if isinstance(i,int): i+=1
   elif isinstance(i,float):i+=1.0
   elif isinstance(i,str):i+="!"
   elif isinstance(i, tuple):i+=(4,5,6)
   elif isinstance(i, list):i+=[4,5,6]
   elif isinstance(i, set):i.add(4)
   elif isinstance(i, dict):
       i.update({'sex': 'male'})

   add2 = id(i)
   print("变量类型", t, "更改值", i, "更改内存地址", id(i))

   if add1 == add2:
       print("显而易见，该变量类型原地可更改！！！")
   else:
       print("显而易见，该变量类型不可原地更改！")
   print('*' * 10)



#以下是上课内容
def use_list():
   demo_list = [1, 2, 3]  # demo_list是一个列表

   print(demo_list)
   print("定义列表后的内存地址 %d" % id(demo_list))

   print(demo_list[0])
   print(demo_list[1])
   print(demo_list[2])
   demo_list[0] = 10
   print("改变后列表的内存地址 %d" % id(demo_list))
   print(type(demo_list))


# 可变数据类型可以在子函数中去通过其接口修改数据空间中的值
def change(my_list):
   my_list[0] = 20


# 不可变数据类型只能通过赋值运算符对其直接赋值，地址会发生改变
def use_tuple():
   demo_tuple = (1, 2, 3)
   print(id(demo_tuple))
   print(demo_tuple[0])
   demo_tuple = (4, 5, 6)
   print(id(demo_tuple))


def use_same_tuple():
   tuple1 = (1, 2, 3)
   tuple2 = (1, 2, 3)
   print(id(tuple1))
   print(id(tuple2))


def use_hash():
   print(hash("xiaoming"))
   print(hash("xiaoming"))


if __name__ == '__main__':
   # demo_list1 = [1, 2, 3]
   # change(demo_list1)
   # print(demo_list1)
   # use_tuple()
   # use_same_tuple()
   use_hash()